﻿<%@ WebHandler Language="C#" Class="TaskHandler" %>

using System;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using Activity;
using Activity.API;

public class TaskHandler : BaseHandler
{

    public TaskHandler()
    {
        //修改请求为post 方式
        base._httpReuqest = base.Context.Request.Form;
    }

    public void GetShopList()
    {
        var bigAreaName = _httpReuqest["bigAreaName"];
        var areaName = _httpReuqest["areaName"];
        var shopStr = _httpReuqest["shopStr"];
        var handler = new TaskSetHandler();
        var group = handler.GetShopList(bigAreaName, areaName, shopStr);
        if (group == null)
        {
            Error("获取数据异常");
        }
        else
        {
            Success(group);
        }
    }

    public void GetAreaList()
    {
        var handler = new TaskSetHandler();
        var list = handler.GetAreaList();
        if (list == null)
        {
            Error("获取数据异常");
        }
        else
        {
            Success(list);
        }
    }

    public void SaveTask()
    {
        var taskID = _httpReuqest["taskID"];
        var taskName = _httpReuqest["taskName"];
        var taskType = _httpReuqest["taskType"];
        var picMax = _httpReuqest["picMax"];
        var desc = _httpReuqest["desc"];
        var UserID = _httpReuqest["UserID"];
        var isEnabled = _httpReuqest["isEnabled"];
        var isMustFinish = _httpReuqest["isMustFinish"];
        var execWeek = _httpReuqest["execWeek"];
        var shopListStr = _httpReuqest["shopList"];
        var handler = new TaskSetHandler();
        if (string.IsNullOrEmpty(taskID))
        {
            var cResult = handler.CreateTask(UserID, taskName, taskType, execWeek, picMax, isEnabled, isMustFinish, desc, shopListStr);
            if (cResult != -1)
            {
                if (cResult == 1)
                {
                    Success(cResult);
                }
                else
                {
                    Error("该任务类型已存在!");
                }
            }
            else
            {
                Error("保存出错");
            }
        }
        else
        {
            var cResult = handler.UpdateTask(UserID, taskID, taskName, taskType, execWeek, picMax, isEnabled, isMustFinish, desc, shopListStr);
            if (cResult != -1)
            {
                if (cResult == 1)
                {
                    Success(cResult);
                }
                else
                {
                    Error("该任务类型已存在!");
                }
            }
            else
            {
                Error("保存出错");
            }
        }
    }

    public void DeleteTask()
    {
        var taskID = _httpReuqest["taskID"];
        var handler = new TaskSetHandler();
        var result = handler.DeleteTask(taskID);
        if (result != -1)
        {
            Success(result);
        }
        else
        {
            Error("删除出错");
        }
    }

    public void GetTask()
    {
        var taskID = _httpReuqest["taskID"];
        var handler = new TaskSetHandler();
        var task = handler.GetTask(taskID);
        if (task != null)
        {
            Success(task);
        }
        else
        {
            Error("获取出错");
        }
    }

    public void GetTaskList()
    {
        var handler = new TaskSetHandler();
        var taskList = handler.GetTaskList();
        if (taskList != null)
        {
            Success(taskList);
        }
        else
        {
            Error("获取出错");
        }
    }

    public void GetShopPermissionsList()
    {
        var proviceName = _httpReuqest["proviceName"];
        var areaName = _httpReuqest["areaName"];
        var shopStr = _httpReuqest["shopStr"];
        var partName = _httpReuqest["partName"];
        var handler = new ShopPermissionsHandler();
        var list = handler.GetShopPermissionsList(proviceName, areaName, shopStr, partName);
        if (list != null)
        {
            Success(list);
        }
        else
        {
            Error("获取出错");
        }
    }

    public void ImportShopPermissionsList()
    {
        var jsonData = _httpReuqest["jsonData"];
        var handler = new ShopPermissionsHandler();
        var result = handler.ImportShopPermissionsList(jsonData);
        if (result == 0)
        {
            Success(result);
        }
        else
        {
            Error("导入出错!");
        }
    }

    public void GetDisplayList()
    {
        var handler = new ShopPermissionsHandler();
        var result = handler.GetDisplayList();
        if (result != null)
        {
            Success(result);
        }
        else
        {
            Error("获取出错");
        }
    }

    public void DeleteShopPermissions()
    {
        var jsonData = _httpReuqest["jsonData"];
        var handler = new ShopPermissionsHandler();
        var result = handler.DeleteShopPermissions(jsonData);
        if (result == 0)
        {
            Success(result);
        }
        else
        {
            Error("删除出错!");
        }
    }

    public void GetShopAreaList()
    {
        var handler = new ShopPermissionsHandler();
        var result = handler.GetShopAreaList();
        if (result != null)
        {
            Success(result);
        }
        else
        {
            Error("获取出错");
        }
    }

    public void GetTaskReport()
    {
        var OperatorAreaName = _httpReuqest["OperatorAreaName"];
        var StartDate = _httpReuqest["StartDate"];
        var EndDate = _httpReuqest["EndDate"];
        var handler = new TaskReportHandler();
        var result = handler.GetTaskReport(OperatorAreaName, StartDate, EndDate);
        if (result != null)
        {
            Success(result);
        }
        else
        {
            Error("获取出错");
        }
    }

    #region 年KM终端督导巡店检查表
    //头部数据
    public void GetBaseModelTab()
    {
        var handler = new ShopInspectionResultsHandler();
        var tifid = _httpReuqest["tifid"];
        var shopName = _httpReuqest["shopName"];
        var checkDate = _httpReuqest["checkDate"];
        var result = handler.GetBaseModelTab(tifid, shopName, checkDate);
        if (result != null)
        {
            Success(result);
        }
        else
        {
            Error("获取出错");
        }
    }
    //人员状况检查
    public void GetStatusCheck()
    {
        var handler = new ShopInspectionResultsHandler();
        var tifid = _httpReuqest["tifid"];
        var shopName = _httpReuqest["shopName"];
        var checkDate = _httpReuqest["checkDate"];
        var ins_parentName = _httpReuqest["ins_parentName"];

        var result = handler.GetStatusCheck(tifid, shopName, checkDate, ins_parentName);
        if (result != null)
        {
            Success(result);
        }
        else
        {
            Error("无数据!");
        }
    }
    //获取九大类设定 
    public void getSettingList()
    {
        var handler = new ShopInspectionResultsHandler();
        var tifid = _httpReuqest["tifid"];
        var shopName = _httpReuqest["shopName"];
        var checkDate = _httpReuqest["checkDate"];
        var result = handler.getSettingList(tifid, shopName, checkDate);
        if (result != null)
        {
            Success(result);
        }
        else
        {
            Error("无数据!");
        }
    }


    //门店列表
    public void GetShopNameList()
    {
        var handler = new ShopInspectionResultsHandler();
        var shopName = _httpReuqest["shopName"];
        var result = handler.GetShopNameList(shopName);
        if (result != null)
        {
            Success(result);
        }
        else
        {
            Error("无数据!");
        }
    }
    //时间
    public void GetTimeList()
    {
        var handler = new ShopInspectionResultsHandler();
        var shopName = _httpReuqest["shopName"];
        var result = handler.GetTimeList(shopName);
        if (result != null)
        {
            Success(result);
        }
        else
        {
            Error("无数据!");
        }
    }

    public void ExportToWordTest()
    {
        var handler = new ExportToWordTestHandler();
        handler.Test3();
    }


    public void ExportShopInspectionResults()
    {
        var tifid = _httpReuqest["tifid"];
        var shopName = _httpReuqest["shopName"];
        var checkDate = _httpReuqest["checkDate"];
        var handler = new ShopInspectionResultsHandler();
        var result = handler.Export(tifid, shopName, checkDate);
        Success(result);
    }

    #endregion


}